#include "login_widget.h"
#include "ui_login_widget.h"

login_widget::login_widget (QWidget *parent) :
	QWidget (parent),
	ui (new Ui::login_widget),
	rwp (new register_widget),
	flp (new FaceLogin),
	Mainfucp (new MainFunction)
{
	ui->setupUi (this);
	
	//全部clear
	ui->lineEditAccount->setClearButtonEnabled (true);
	ui->lineEditPassword->setClearButtonEnabled (true);
	
	//密码隐藏
	ui->lineEditPassword->setEchoMode (QLineEdit::Password);
	
	//picture
	const QString ImagePath = QCoreApplication::applicationDirPath() + "/image/";
	QImage img;
	img.load ("index.jpg");
	QImage _img = img.scaled (ui->labelPicture->width(), ui->labelPicture->height());
	ui->labelPicture->setPixmap (QPixmap::fromImage (_img));
	ConnectSlots();
}

login_widget::~login_widget()
{
	delete ui;
}

void
login_widget::ConnectSlots()
{
	//密码登录按钮
	connect (ui->pushButtonPasswordLogin,
	         SIGNAL (clicked()), this, SLOT (on_pushButtonLogin_clicked()));
	//刷脸登录按钮
	connect (ui->pushButtonFaceLogin,
	         SIGNAL (clicked()), this, SLOT (on_pushButtonFaceLogin_clicked()));
	         
	//注册按钮
	connect (ui->pushButtonRegister,
	         SIGNAL (clicked()), this, SLOT (on_pushButtonRegister_clicked()));
	         
}

void
login_widget::on_pushButtonRegister_clicked()
{
	this->hide();
	rwp->show();
}

void
login_widget::on_pushButtonLogin_clicked()
{
	this->hide();
	Mainfucp->show();
}

void
login_widget::on_pushButtonFaceLogin_clicked()
{
	this->hide();
	flp->show();
}

